<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>PC应用示例-编辑页</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
  <h1 class="page-header"><a href="./list">PC应用示例</a></h1>
  <div class="row">
    <div class="col-md-12">
      <div class="panel panel-warning">
      <div class="panel-heading">
        <h2 class="text-center">编辑新闻</h2>
      </div>
        <div class="panel-body">
      <div class="form-horizontal">
        <div class="form-group">
          <label for="title" class="col-sm-2 control-label">标题</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" value="{{ info.title }}" id="title" placeholder="新闻标题">
          </div>
        </div>
        <div class="form-group">
          <label for="description" class="col-sm-2 control-label">标签</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" value="{{ info.label }}" id="label" placeholder="新闻标签">
          </div>
        </div>
        <div class="form-group">
          <label for="description" class="col-sm-2 control-label">简介</label>
          <div class="col-sm-10">
            <textarea class="form-control" rows="4" id="description" placeholder="新闻简介">{{ info.description }}</textarea>
          </div>
        </div>
        <div class="form-group">
          <label for="content" class="col-sm-2 control-label">内容</label>
          <div class="col-sm-10">
            <textarea class="form-control" rows="12" id="content" placeholder="新闻内容">{{ info.content }}</textarea>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">
            <input type="hidden" name="id" id="id" value="{{ info.id }}">
            <button class="btn btn-default" onclick="saveData()">保存</button>
          </div>
        </div>
      </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
    function saveData(){
        var url ='{{site_url}}/module/demo_engine_pc/save';
        console.log(url)
        var id = $('#id').val();
        var title = $('#title').val();
        var label = $('#label').val();
        var description = $('#description').val();
        var content = $('#content').val();
        $.post(url, {id:id,title:title,label:label,description:description,content:content}, function(data) {
            if (0 == data.code) {
                alert(data.message)
                window.location.href = '{{site_url}}/module/demo_engine_pc/list';
            }
        });
    }
</script>
</body>
</html>